<template>
	<view>
		<view class="main">
			<view v-if="lists && lists.length > 0" class="lists">
				<view class="items" v-for="(item, index) in lists" :key="index">
					<view class="title">
						<text>{{item.merchant_name}}</text>
					</view>
					<view class="item">
						<view class="left">
							<text>{{item.sn}}</text>
							<u-icon name="/static/copy.png" color="#c8c9cc" size="18"></u-icon>
						</view>
						<view class="right fee"></view>
					</view>
					<view class="item">
						<view class="left">
							<text>{{item.active_time_text}}</text>
						</view>
						<view class="right">
							<text>激活成功</text>
						</view>
					</view>
				</view>
			</view>
			<u-empty class="policy_box" v-else mode="list" icon="/static/Empty/data_null.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				agentId: '',
				productId: '',
				day: '',
				lists: [],
				page: 1,
				page_size: 10,
				bottom: true,
			}
		},
		filters: {
			formatDate(value) {
				if (value) {
					return new Date(value * 1000).toLocaleString(); // 转换为本地日期和时间字符串
				}
			}
		},
		onLoad(e) {
			this.day = e.day
			this.agentId = e.agentId
			this.productId = e.productId
			this.loadData()
		},
		//下拉刷新
		onReachBottom() {
			if (this.bottom == true) {
				this.page += 1
				this.loadData()
			}
		},
		methods: {
			// 加载数据
			async loadData() {
				uni.showLoading({
					title: '加载中'
				});
				const {
					data: res
				} = await this.$myHttp({
					url: 'v1/getHzyActiveTotalDay',
					data: {
						page: this.page,
						agentId: this.agentId,
						productId: this.productId,
						day: this.day
					}
				});
				uni.hideLoading()
				if (res.code == 200) {
					if (res.data.data !== undefined && res.data.data !== null && res.data.data.length > 0) {
						if (this.page == 1) {
							this.lists = res.data.data
						} else {
							this.lists = [...this.lists, ...res.data.data]
						}
					} else {
						this.bottom = false
					}
				} else {
					this.bottom = false
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		.lists {
			padding: 0 30rpx;
			background-color: #ffffff;

			.items {
				padding: 30rpx 0;
				border-bottom: 1px solid #f4f4f5;

				.item {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding-top: 20rpx;
					font-size: 28rpx;

					.left {
						display: flex;

						text {
							padding-right: 10rpx;
						}
					}

					.fee {
						color: #19be6b;
					}
				}
			}
		}
	}
</style>